if (typeof flowUtil == 'undefined') {
    flowUtil = {};
}
flowUtil.startFlow = function (modelId) {
    var url =  "/workflow/actDefModel/getCanDirectStart";
    var params = {modelId:modelId};
    $.ajax({
        url: url,
        type: 'POST',
        dataType: 'json',
        data:params
    })
        .done(function(data) {
            if (data.data){
                layui.use('layer',function () {
                    var layer = layui.layer;
                    layer.alert('直接启动流程流程实例可能会报错，需要启动流程吗?', {
                        icon: 0,
                        skin: 'layui-layer-orange',
                        closeBtn: 1,
                        btn: ['确定', '取消'],
                        btn1: function () {
                           var setter = layui.setter;
                            var url =  setter.workflowLinkPath +"task/view/startFlowForm?modelId=" + modelId;
                            window.open(url);
                            layer.closeAll();
                        }
                    })
                });

            } else {
                var setter = layui.setter;
                var url = setter.workflowLinkPath +"task/view/startFlowForm?modelId=" + modelId;
                window.open(url);
            }
        })
        .fail(function() {
            alert('服务器超时，请重试！');
        });
};